import request from '@/utils/request';

// 获取所有平台
export function getPlat(query) {
    return request({
        url: 'count/getPlat',
        method: 'get',
        params: query
    });
}
// 用户统计
export function getUserCount(query) {
    return request({
        url: 'count/getUserCount',
        method: 'get',
        params: query
    });
}
// 店铺列表
export function getShop(query) {
    return request({
        url: 'count/getShop',
        method: 'get',
        params: query
    });
}

// 商品统计
export function getShopCount(query) {
    return request({
        url: 'count/getShopCount',
        method: 'get',
        params: query
    });
}

// 品牌统计导出
export function exportBrandCount(startTime,endTime,shopId ) {
    return request({
        url: '/count/exportBrandCount?startTime=' + startTime +'&endTime=' +endTime+'&shopId='+shopId,
        method: 'get'
    });
}
/*export function exportBrandCount(startTime, endTime, shopId) {
    if (window.navigator.msSaveBlob) {
        // IE以及IE内核的浏览器
        try {
            window.navigator.msSaveBlob(res, fileName); // res为接口返回数据，这里请求的时候已经处理了，如果没处理需要在此之前自行处理var data = new Blob([res.data]) 注意这里需要是数组形式的,fileName就是下载之后的文件名
            // window.navigator.msSaveOrOpenBlob(res, fileName);  //此方法类似上面的方法，区别可自行百度
        } catch (e) {
            console.log(e);
        }
    } else {
        let link = document.createElement('a');
        link.href = process.env.VUE_APP_BASE_API + '/count/exportBrandCount?startTime=' + startTime +'&endTime=' +endTime+'&shopId='+shopId;
        // let url = window.URL.createObjectURL(new Blob([res]))
        link.style.display = 'none';
        document.body.appendChild(link);
        link.click();
        document.body.removeChild(link); // 下载完成移除元素
        window.URL.revokeObjectURL(url); // 释放掉blob对象
    }
}*/

// 品牌统计
export function getBrandCount(query) {
    return request({
        url: 'count/getBrandCount',
        method: 'get',
        params: query
    });
}
// 品类统计导出
export function exportCategoryCount(startTime, endTime, shopId, categoryId) {
    return request({
        url: '/count/exportCategoryCount?startTime=' + startTime +'&endTime=' +endTime+'&shopId='+shopId+'&categoryId='+categoryId,
        method: 'get'
    });
}

// 获取品类列表
export function getCategoryList(query) {
    return request({
        url: 'count/getCategoryList',
        method: 'get',
        params: query
    });
}

// 单品统计导出
export function exportItemRankCount(startTime, endTime) {
    return request({
        url: '/count/exportItemRank?startTime=' + startTime +'&endTime=' +endTime,
        method: 'get'
    });
}

// 品类统计
export function getCategoryCount(query) {
    return request({
        url: 'count/getCategoryCount',
        method: 'get',
        params: query
    });
}

// 单品排行
export function getItemRank(query) {
    return request({
        url: 'count/getItemRank',
        method: 'get',
        params: query
    });
}

// 获取充值渠道
export function getCompany() {
    return request({
        url: 'count/getCompany',
        method: 'get'
    });
}

// 资金统计
export function getFundCount(query) {
    return request({
        url: 'count/getFundCount',
        method: 'get',
        params: query
    });
}

// 采购金额统计
export function getPurchaseAmount(query) {
    return request({
        url: 'count/getPurchaseAmount',
        method: 'get',
        params: query
    });
}

// 订单按天统计下单数量
export function getOrderDayCount(query) {
    return request({
        url: 'count/getOrderDayCount',
        method: 'get',
        params: query
    });
}
// 订单按年统计下单数量
export function getOrderYearCount(query) {
    return request({
        url: 'count/getOrderYearCount',
        method: 'get',
        params: query
    });
}
